package com.zkingsoft.actions.admin.bus;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zkingsoft.constraint.BaseController;
import com.zkingsoft.model.bus.BusArea;
import com.zkingsoft.pojo.AjaxResult;
import com.zkingsoft.services.bus.BusAreaService;
@Controller
@RequestMapping(value = "/admin/busArea")
public class BusAreaController  extends BaseController{
	
	@Resource
	private BusAreaService busAreaService;

	/**
	 * 列表显示
	 */
	@RequestMapping(value = "/showList")
	public @ResponseBody AjaxResult showList(Long parentId) {
		List<BusArea> dataList = busAreaService.findChildArea(parentId);
		AjaxResult result = new AjaxResult(AjaxResult.STATUS_OK, null, null, dataList, 0);
		return result;
	}
	/**
	 * 根据父级地区名称查询子地区
	 */
	@RequestMapping(value = "/findArea")
	public @ResponseBody AjaxResult findArea(HttpServletResponse response,String areaName) {
		List<BusArea> dataList = busAreaService.findChildrenAreaByName(areaName);
		AjaxResult result = new AjaxResult(AjaxResult.STATUS_OK, null, null, dataList, 0);
		return result;
	}
	
	/**
	 * 根据父级主键查找子地区
	* @Title: findById 
	* @Description: TODO
	* @param busArea
	* @return    设定文件 
	* @author 肖崇高
	 */
	@RequestMapping(value = "/findById")
	public @ResponseBody AjaxResult findById(BusArea busArea) {
		System.out.println("area = "+busArea);
		List<BusArea> dataList = busAreaService.findChildArea(busArea.getParentId());
		AjaxResult result = new AjaxResult(AjaxResult.STATUS_OK,dataList);
		return result;
	}
}
